package com.example.extest;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.CheckBox;
import android.widget.Toast;

public class ActivityCheckbox extends Activity {
	// @Override
	public void onCreate(Bundle state) {
		super.onCreate(state);
		setContentView(R.layout.layout_checkbox);
		
		Log.i("log test e 1111", "1111111111");
		
		chk1();
		chk2();
		chk3();
	}
	
	public void chk1(){
		CheckBox chk = (CheckBox)findViewById(R.id.checkBox1);
		
		chk.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View arg0) {
				// TODO Auto-generated method stub
				//Toast.makeText(ActivityCheckbox.this, "Checkbox 1", Toast.LENGTH_LONG).show();
				Log.i("log test e 222", "22222");
				showToastCheckbox();
			}
		});
	}
	
	public void chk2(){
		CheckBox chk = (CheckBox)findViewById(R.id.checkBox2);
		
		chk.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View arg0) {
				// TODO Auto-generated method stub
				//Toast.makeText(ActivityCheckbox.this, "Checkbox 2", Toast.LENGTH_LONG).show();
				Log.i("log test e 3333", "333333");
				showToastCheckbox();
			}
		});
	}
	
	public void chk3(){
		CheckBox chk = (CheckBox)findViewById(R.id.checkBox3);
		
		chk.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View arg0) {
				// TODO Auto-generated method stub
				//Toast.makeText(ActivityCheckbox.this, "Checkbox 3", Toast.LENGTH_LONG).show();
				Log.i("log test e 4444", "4444444");
				showToastCheckbox();
			}
		});
	}
	
	public void showToastCheckbox(){
		CheckBox chk1 = (CheckBox)findViewById(R.id.checkBox1);
		CheckBox chk2 = (CheckBox)findViewById(R.id.checkBox2);
		CheckBox chk3 = (CheckBox)findViewById(R.id.checkBox3);
		StringBuffer result = new StringBuffer();
		result.append("Checkbox 1 : ").append(chk1.isChecked());
		result.append("\nCheckbox 2 : ").append(chk2.isChecked());
		result.append("\nCheckbox 3 : ").append(chk3.isChecked());

		Log.i("log test e 5555", "5555");
		Toast.makeText(ActivityCheckbox.this, result.toString(),Toast.LENGTH_LONG).show();
	}
}
